package com.user.profile.service.user;

import com.user.profile.entity.UserEntity;
import com.user.profile.perm.ClickHousePerm;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @Author linlx
 * @Date 2021/9/22 11:36
 * @Description
 **/
@Service
public class AgeInsertBuildImpl implements InsertBuild {

  @Resource
  private CommonInsertBuild commonInsertBuild;

  @Override
  public List<String> build(List<UserEntity> dataList) {
    Map<Integer, List<UserEntity>> ageMap = dataList.stream()
        .collect(Collectors.groupingBy(UserEntity::getAge));
    return commonInsertBuild.buildLabelInt(ageMap, ClickHousePerm.INSERT_AGE);
  }
}
